package controller.model;


import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;

import vision.Provider;

import controller.acquaintance.I_WorkCellController_OEE;
import controller.acquaintance.I_WorkCellController_PackML;
import controller.acquaintance.I_WorkCellController_PackmlHandler;
import controller.acquaintance.I_WorkCellController_Vision;

public class WorkCellControllerServer
{
	public static String rmiPackML = "rmi://localhost/WorkCellControllerPackML";
	public static String rmiVision = "rmi://localhost/WorkCellControllerVision";
	public static String rmiPackMLHandler = "rmi://localhost/WorkCellControllerPackMLHandler";
	public static String rmiOEE = "rmi://localhost/WorkCellControllerOEE";
	
	public static void main(String[] args) throws RemoteException, MalformedURLException
	{
		java.rmi.registry.LocateRegistry.createRegistry(1099);
		
		final WorkCellControllerImpl controller = new WorkCellControllerImpl();
		
		I_WorkCellController_PackML packML = controller;
		I_WorkCellController_Vision vision = controller;
		I_WorkCellController_PackmlHandler handler = controller;
		I_WorkCellController_OEE oee = controller;
		
		Naming.rebind(rmiPackML, packML);
		Naming.rebind(rmiVision, vision);
		Naming.rebind(rmiPackMLHandler, handler);
		Naming.rebind(rmiOEE, oee);
		
		System.out.println("Workcell controller is running");

		//Start subsystems
		
		controller.instantiateSubSystems();
		
		Provider p = new Provider();
		p.start();
	}
}
